#!/bin/bash

# 注意打包web 的时候 最好是 flutter clean 再删除 build文件 再 flutter pub get 一遍 这样确保没有问题
flutter clean
rm -r build
flutter pub get

content=$(grep "version:" pubspec.yaml)
version=$(echo "$content" | sed 's/version: //g')

echo $version

# 根据传入参数设置 buildName
if [[ $1 == "release" ]]; then
    buildName="正式环境"
else
    buildName="有错误弹窗的调试版本"
fi

echo $buildName

#这里的需求只是要打个release包的apk 即可
flutter build apk --target-platform android-arm64 --split-per-abi --tree-shake-icons  --dart-define=APP_ENV=$1
cd ./build/app/outputs/flutter-apk
cp app-arm64-v8a-release.apk ${buildName}_${version}.apk
mv ${buildName}_${version}.apk ../../../../
cd ../../../../


#cd ./build
#
#flutter build web --base-href /  --dart-define=APP_ENV=$1
#
### 判断条件
##if [[ $1 == "release" ]];then
##    zip -r web-${version}.zip web
##    mv web-${version}.zip ..
##else
##    zip -r $1-${version}.zip web
##    mv $1-${version}.zip ..
##fi
#
#zip -r $1_${version}.zip web
#mv $1_${version}.zip ..